﻿@page "/GridSortData"
@layout DataProviderAccessArea<INwindDataProvider>

<DemoPageSectionComponent Id="DataGrid-Sorting" ShowHorizontalScrollBar="true">
    @inject NwindDataService NwindDataService

    @if(Data == null) {
        <p><em>Loading...</em></p>
    } else {
        <DxDataGrid Data="@Data">
            <DxDataGridColumn Field="@nameof(Customer.CustomerId)" Caption="ID" AllowSort="false" Width="80px" />
            <DxDataGridColumn Field="@nameof(Customer.ContactName)" />
            <DxDataGridColumn Field="@nameof(Customer.CompanyName)" />
            <DxDataGridColumn Field="@nameof(Customer.City)" SortIndex="1" SortOrder="DataGridColumnSortOrder.Ascending" Width="200px" />
            <DxDataGridColumn Field="@nameof(Customer.Country)" SortIndex="0" SortOrder="DataGridColumnSortOrder.Ascending" Width="200px" />
        </DxDataGrid>
    }

    @code {
        IEnumerable<Customer> Data { get; set; }

        protected override async Task OnInitializedAsync() {
            Data = await NwindDataService.GetCustomersAsync();
        }
    }
</DemoPageSectionComponent>
